package com.example.demo.manmanage.controller;

import com.example.demo.manmanage.service.ManService;
import net.sf.json.JSONObject;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@Transactional
@CrossOrigin
public class ManController {

    private Logger log = Logger.getLogger(ManController.class);

    @Autowired
    private ManService manService;

    /**
         * @Description 根据条件查询所有司机信息
         * @Author zhangxue
         * @Date 17:34 2018/7/11
         * @Param
         * @retrun
         **/
    @RequestMapping(value="/queryAllMen",method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    @ResponseBody
    public Map<String,Object> queryAllMen(@RequestBody Map<String,Object> param){
        Map<String,Object> statusMap = manService.queryAllMen(param);
        return statusMap;
    }

    /**
     * @Description 查询司机姓名下拉
     * @Author zhangxue
     * @Date 8:53 2018/6/3
     * @Param
     * @retrun
     **/
    @RequestMapping(value="/queryAllSjName")
    @ResponseBody
    public String queryAllSjName(){
        JSONObject js= new JSONObject();
        Map<String,Object> resultMap = new HashMap<String, Object>();
        Map<String,Object> param = new HashMap<String, Object>();
        List<Map<String,Object>> resultList = manService.queryAllSjName(param);
        resultMap.put("data",resultList);
        js = JSONObject.fromObject(resultMap);
        return js.toString();
    }

    /**
     * @Description 根据条件查询所有空闲司机信息
     * @Author zhangxue
     * @Date 17:34 2018/7/11
     * @Param
     * @retrun
     **/
    @RequestMapping(value="/queryAllFreeMen",method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    @ResponseBody
    public Map<String,Object> queryAllFreeMen(@RequestBody Map<String,Object> param) {
        Map<String, Object> statusMap = manService.queryAllFreeMen(param);
        return statusMap;
    }

        /**
             * @Description 新增驾驶人员信息
             * @Author zhangxue
             * @Date 11:18 2018/7/12
             * @Param
             * @retrun
             **/
    @RequestMapping(value="/saveMan",method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    @ResponseBody
    public Map<String,Object> saveMan(@RequestBody Map<String,Object> param){
        Map<String,Object> statusMap = manService.saveMan(param);
        return statusMap;
    }

    /**
         * @Description 删除驾驶人员信息
         * @Author zhangxue
         * @Date 14:30 2018/7/13
         * @Param
         * @retrun
         **/
    @RequestMapping(value="/delMan",method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    @ResponseBody
    public Map<String,Object> delMan(@RequestBody Map<String,Object> param){
        Map<String,Object> statusMap = manService.delMan(param);
        return statusMap;
    }

    /**
         * @Description 修改驾驶人员信息
         * @Author zhangxue
         * @Date 17:48 2018/7/13
         * @Param
         * @retrun
         **/
    @RequestMapping(value="/editMan",method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    @ResponseBody
    public Map<String,Object> editMan(@RequestBody Map<String,Object> param){
        Map<String,Object> statusMap = manService.editMan(param);
        return statusMap;
    }

    /**
         * @Description 查看驾驶人员详情
         * @Author zhangxue
         * @Date 16:16 2018/7/13
         * @Param
         * @retrun
         **/
    @RequestMapping(value="/initManInfo",method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    @ResponseBody
    public Map<String,Object> initManInfo(@RequestBody Map<String,Object> param){
        Map<String,Object> resultMap = manService.initManInfo(param);
        return resultMap;
    }
//
//    /**
//         * @Description 添加授权书资料路径
//         * @Author zhangxue
//         * @Date 11:37 2018/7/13
//         * @Param
//         * @retrun
//         **/
//    @RequestMapping(value="/uploadBook",method = RequestMethod.POST,produces = "application/json;charset=utf-8")
//    @ResponseBody
//    public Map<String,Object> uploadBook(@RequestBody Map<String,Object> param){
//        Map<String,Object> statusMap = manService.saveUploadBook(param);
//        return statusMap;
//    }
//
//    /**
//     * @Description 添加执照路径
//     * @Author zhangxue
//     * @Date 11:37 2018/7/13
//     * @Param
//     * @retrun
//     **/
//    @RequestMapping(value="/uploadLicense",method = RequestMethod.POST,produces = "application/json;charset=utf-8")
//    @ResponseBody
//    public Map<String,Object> uploadLicense(@RequestBody Map<String,Object> param){
//        Map<String,Object> statusMap = manService.saveUploadLicense(param);
//        return statusMap;
//    }
//
//    /**
//         * @Description 添加身份证照片
//         * @Author zhangxue
//         * @Date 17:06 2018/7/16
//         * @Param
//         * @retrun
//         **/
//    @RequestMapping(value="/uploadCard",method = RequestMethod.POST,produces = "application/json;charset=utf-8")
//    @ResponseBody
//    public Map<String,Object> uploadCard(@RequestBody Map<String,Object> param){
//        Map<String,Object> statusMap = manService.saveUploadCard(param);
//        return statusMap;
//    }
//
//    /**
//         * @Description 新增展位信息
//         * @Author zhangxue
//         * @Date 15:09 2018/7/13
//         * @Param
//         * @retrun
//         **/
//    @RequestMapping(value="/saveZWInfo",method = RequestMethod.POST,produces = "application/json;charset=utf-8")
//    @ResponseBody
//    public Map<String,Object> saveZWInfo(@RequestBody Map<String,Object> param){
//        Map<String,Object> statusMap = manService.saveZWInfo(param);
//        return statusMap;
//    }
//
//    /**
//         * @Description 删除展位信息
//         * @Author zhangxue
//         * @Date 17:00 2018/7/13
//         * @Param
//         * @retrun
//         **/
//    @RequestMapping(value="/delZWInfo",method = RequestMethod.POST,produces = "application/json;charset=utf-8")
//    @ResponseBody
//    public Map<String,Object> delZWInfo(@RequestBody Map<String,Object> param){
//        Map<String,Object> statusMap = manService.delZWInfo(param);
//        return statusMap;
//    }
}
